package com.xmsx.back.mapper.admin;

import com.xmsx.back.pojo.Graduate;
import com.xmsx.back.pojo.Job;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface JobMapper {

    /**
     * 获取某个招聘信息的所有数据
     * @param id
     * @return
     */
    @Select("select * from job where id = #{id}")
    Job getById(@Param("id") int id);

    /**
     * 插入招聘信息
     * @param job
     */
    @Insert("insert into job values(#{job.id},#{job.title},#{job.ddl},#{job.website}," +
            "#{job.email},#{job.content},#{job.datetime})")
    void setJob(@Param("job") Job job);

    /**
     * 修改招聘信息
     * @param job
     */
    @Insert("update job set title=#{job.title}, ddl=#{job.ddl}, website=#{job.website}, " +
            "email=#{job.email}, content=#{job.content}, datetime=#{job.datetime}")
    void updateJob(@Param("job") Job job);

    /**
     * 删除招聘信息
     * @param id
     */
    @Select("delete from job where id=#{id}")
    void deleteJob(@Param("id") int id);

    /**
     * 统计记录数
     * @return
     */
    @Select("select count(1) from job")
    long count();

    @Select("select * from job order by datetime desc, website desc limit #{page},#{size} ")
    List<Job> findByPager(Map<String, Object> params);
}
